import { CallStatus } from "./call";

// 区分 是单聊还是群聊
export enum ChatType {
  friend = 1,
  group = 2,
  friendNotify = 3,
  heartBeat = 4,
}

// 区分消息类型
export enum MessageType {
  text = 0,
  image = 1,
  file = 2,
  mixTxtImg = 3,
  voiceCall = 4,
  videoCall = 5,
  requestAdd = 6,
  friendOnline = 7,
  friendOff = 8,
  withdraw = 9, // 撤回消息
  quotation = 10, //消息引用
}

// 发送消息的状态
export enum MessageStatus {
  wait = 0,
  success = 1,
  error = 2,
  cancel = 3,
}

type TacticMessageType =
  | MessageType.text
  | MessageType.image
  | MessageType.file
  | MessageType.mixTxtImg
  | MessageType.voiceCall
  | MessageType.videoCall
  | MessageType.requestAdd
  | MessageType.withdraw
  | MessageType.quotation;

interface IMessageInfo {
  name: string;
  avatar: string;
}

interface IMessage {
  uuid: string;
  sendId: number;
  toId: number;
  sessionId: string;
  messageType: number;
  chatType: number;
  callStatus: CallStatus;
  status: MessageStatus;
  createdAt: string;
  updatedAt: string;
  groupId?: number;
  content?: any;
  quotationId?: string; //消息引用id
  aitIds?: string; // @ userId
  fileName?: string;
  localPath?: string;
  fileUrl?: string;
  fileSize?: number;
  upload?: boolean;
  progress?: number;
}

interface IChatObj {
  id: number;
  sessionId: string;
  chatType: number;
  avatar: string;
  name: string;
}

interface IFile {
  file: File;
  viewUrl: string;
  type: number;
}

export type { IMessage, IFile, IChatObj, TacticMessageType, IMessageInfo };
